{extends file="main.tpl"}
{block name=head}
<script type="text/javascript">
  $(document).ready(function() {
  	$(".redate").hide();
	  balnace();
	
  $("#partyName").autocomplete("getPartyAj.php", 
	{   
		width: 400,     
		matchContains: true,
		mustMatch: false,
		minChars: 0,
		highlight: false,
		selectFirst: true,
		formatItem: function(data, i, n, value) {   
		  return  value.split("|")[0];
	  }
  }); 
  $("#partyName").result(function(event, data, formatted) {
	  $("#partyId").val(data[1]);
	  balnace();
  });      
});
function balnace()
{
	  var dataString = "partyId=" + $('#partyId').val();
	  $.ajax({
	  type: "GET",
	  url: "balanceAj.php",
	  data : dataString,
	  success:function(data){ 
  	  $('#partyBalance').val(data);
	  }
	 });
}
$('#aimg').click(function()
{
	myFunction();
});
function myFunction()
{
	if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function remind(radioObj)
{
	if($(radioObj).val() == 'Y')
	{
		$(".redate").show();
	}
	else
	{
		$(".redate").hide();
	}
}
</script>
{/block}
{block name=body}
<form name="material" action="{$smarty.server.PHP_SELF}" method="post">
<table align="center" border="0" cellpadding="2" cellspacing="2" >
<input type="hidden" value="{$editArray.transactionId}" name="transactionId">
<tr><td align="center" class="table1" colspan="10">Add Entry</td></tr>
<tr>
	<td align="left" class="table1" colspan="4">Party Name :
		<input type="text" name="partyName" id="partyName" class="partyName" value="{$partyNameSelected}" autofocus=autofocus required />
		<input type="hidden" name="partyId" id="partyId" value="{$partyIdSelected}" />
	  Balance : <input type="text" name="partyBalance" selected="" id="partyBalance" size="6" READONLY /></td>
	<td align="left" class="table1" colspan="4">
		Transaction Date :{html_select_date prefix="curDate" start_year ="-8" end_year="+4" field_order="DMY" month_format="%m" day_value_format="%02d"}
		&nbsp;&nbsp; <br />
		Remind ?
	  <select  name="status" onchange="remind(this);" required />
	    {html_options values=$statusArray output=$statusOutputArray}
    </select>
    <span class="redate">
		  {html_select_date prefix="remind" start_year ="-8" end_year="+4" field_order="DMY" month_format="%m" day_value_format="%02d"}
	  </span>
  </td>
</tr>
<tr>
	<td align="center" class="table1" colspan="2">JAMA</td>
	<td align="center" style="background-color: #008040">&nbsp;&nbsp;</td>
	<td align="center" class="table1" colspan="7">UDHAR</td>
</tr>
<tr>
	<td align="center" class="table1">RUPIYA</td>
	<td align="center" class="table1">VIGAT</td>
	<td align="center" style="background-color: #008040">&nbsp;&nbsp;</td>
	<td align="center" class="table1">RUPIYA</td>
	<td align="center" class="table1">VIGAT</td>
	<td align="center" class="table1">VAJAN</td>
	<td align="center" class="table1" colspan="4">BHAV</td>
</tr>
<tr>
	<td align="center" class="table1"><input type="text" name="jamaRupiya" id="jamaRupiya" value="{$editArray.jamaRupiya}" class="jamaRupiya " /></td>
	<td align="center" class="table1"><input type="text" name="jamaVigat"  id="jamaVigat"  value="{$editArray.jamaVigat}" class="jamaVigat" /></td>
	<td align="center" style="background-color: #008040">&nbsp;&nbsp;</td>
	<td align="center" class="table1"><input type="text" name="udhaarRupiya" id="udhaarRupiya" value="{$editArray.udhaarRupiya}" class="udhaarRupiya " /></td>
	<td align="center" class="table1"><input type="text" name="udhaarVigat"  id=" "  value="{$editArray.udhaarVigat}" class="udhaarVigat" /></td>
	<td align="center" class="table1"><input type="text" name="udhaarVajan"  id="udhaarVajan"  value="{$editArray.udhaarVajan}" class="udhaarVajan " /></td>
	<td align="center" class="table1" colspan="4"><input type="text" name="udhaarBhav"   id="udhaarBhav"   value="{$editArray.udhaarBhav}" class="udhaarBhav " /></td>
</tr>
<tr>
	<td align="center" class="table1" colspan="10">
		<input type="submit" name="submitBtn" value=" SAVE " />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="reset" value=" CANCEL " />
	</td>
</tr>
</table>
</form>
<h2 align="center">Entry List </h2>
<table  border='2' align="center">
<tr>
	<th class="table1">&nbsp;</th>
	<th class="table1">&nbsp;</th>
	<th class="table1">Party Name</th>
	<th class="table1">Jama Rupiya</th>
	<th class="table1">Jama Vigat</th>
	<th class="table1">Udhaar Rupiya</th>
	<th class="table1">Udhaar Vigat</th>
	<th class="table1">Udhaar Vajan</th>
	<th class="table1">Udhaar Bhav</th>
	</tr>
{section name="sec" loop=$transactionArray}
<tr>
	<td class="table2"><a id="aimg" href="transaction.php?transactionId={$transactionArray[sec].transactionId}&partyId={$transactionArray[sec].partyId}" class="link" onclick="return balnace();"><img src="./images/edit.gif"></a></td>
	<td class="table2" align="center">
	  <a href="transDelete.php?transactionId={$transactionArray[sec].transactionId}" onclick="return myFunction();" class="link"><img src="./images/deleteIcon.png" height="20px" width="20px"></a>
	</td>
	<td class="table2" align="left">{$transactionArray[sec].partyName}</td>
	<td class="table2" align="right">{$transactionArray[sec].jamaRupiya}</td>
	<td class="table2" align="left">{$transactionArray[sec].jamaVigat}</td>
	<td class="table2" align="right">{$transactionArray[sec].udhaarRupiya}</td>
	<td class="table2" align="left">{$transactionArray[sec].udhaarVigat}</td>
	<td class="table2" align="right">{$transactionArray[sec].udhaarVajan}</td>
	<td class="table2" align="right">{$transactionArray[sec].udhaarBhav}</td>
</tr>
{/section}
</table>
{/block}